package com.hq.fxh.Utils;

import android.app.DatePickerDialog;
import android.content.Context;
import android.widget.DatePicker;

import java.util.Calendar;

/**
 * /**
 *
 * @author 薛
 * @ClassName
 * @Description :
 * @Created 2017/9/22
 * @Email xlwenhao1858@sina.com
 */


public class TimeSelectUtils {
    DatePickerDialog age;

    public void selectTime(Context context, final TimeCallBack timeCallBack) {
        final Calendar c = Calendar.getInstance();
        int mYear = c.get(Calendar.YEAR);
        int mMonth = c.get(Calendar.MONTH);
        int mDay = c.get(Calendar.DAY_OF_MONTH);
        if (age == null) {
            age = new DatePickerDialog(context, new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                    String time = year + "/" + (month + 1) + "/" + dayOfMonth;

                    timeCallBack.seclectCall(view, year, (month + 1), dayOfMonth, time);
                }
            },
                    mYear, mMonth, mDay);
        }

        age.show();

    }


    public interface TimeCallBack {
        void seclectCall(DatePicker view, int year, int month, int dayOfMonth, String time);

    }

}
